package com.stooges.web;

import com.stooges.domain.User;
import com.stooges.view.ResultView;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.websocket.Session;

/**
 * 登录注册控制中心
 * @author 张超
 * @date 2017/3/28
 */
@Controller
public class LoginController {
    /**
     * 跳转到登录页面
     * @return
     */
    @ApiOperation(value = "跳转到登录页面",notes="跳转到登录页面，不传输任何数据")
    @RequestMapping(value = "/login",method = RequestMethod.GET)
    public String toLogin(){
        return "login";
    }

    /**
     * 登录
     * @return
     */
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    @ApiImplicitParam(name = "user",value = "用户详细实体User",required = true,dataType = "User")
    @ResponseBody
    public ResultView login(@RequestBody User user){
        ResultView resultView = new ResultView();
        //检查User输入对象是否正确
        return resultView;
    }
    @RequestMapping(value = "/logout/{id}")
    public ResultView logout(@PathVariable Long id,Session session){
        ResultView resultView = new ResultView();
        return resultView;
    }

    public String toRegist(){
        return "regist";
    }
    @ResponseBody
    public ResultView regist(@RequestBody User user){
        ResultView resultView = new ResultView();
        return resultView;
    }
}
